package com.sjlh.centurylianhua.controller;

import com.sjlh.centurylianhua.mapper.RoleMapper;
import com.sjlh.centurylianhua.mapper.UserRoleMapper;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/userRole")
@CrossOrigin
public class UserRoleController {
    @Resource
    private UserRoleMapper urm;
    @Resource
    private RoleMapper roleMapper;

    /**为用户赋予角色
     * @param roleIds  角色id通过逗号拼接的字符串
     * @param userId
     * @return
     */
    /*@RequestMapping("/batchSave")
    public Object batchSave(String roleIds,Integer userId) {
        String[] str=roleIds.split(",");
        List<UserRole> list=new ArrayList<UserRole>();
        for(String s:str) {//有多少个roleId，就需要创建多少个对象
            UserRole ur=new UserRole();
            ur.setRoleId(Integer.valueOf(s));
            ur.setUserId(userId);
            list.add(ur);
        }
        //boolean r=urm.findUserAndRole().addAll(list);//批量添加
        //return new ResultUtil("", r);
    }*/

}

